<template>
	<view class="my-userinfo-container">
		<!-- 头像 昵称区域 -->
		<view class="top-box">
			<image :src="userinfo.avatarUrl" mode="" class="avatar"></image>
			<text class="nickname">{{userinfo.nickName}}</text>
		</view>
		<!-- 面版区域 -->
		<view class="panel-list">
			<!-- 第一个panel -->
			<view class="panel-body">

				<!-- 店铺 -->
				<view class="panel-item">
					<text>12</text>
					<text>店铺</text>
				</view>
				<!-- 店铺-->
				<view class="panel-item">
					<text>21</text>
					<text>店铺的商品</text>
				</view>
				<!-- 关注的商品 -->
				<view class="panel-item">
					<text>12</text>
					<text>关注的商品</text>
				</view>
				<!-- 足迹 -->
				<view class="panel-item">
					<text>12</text>
					<text>足迹</text>
				</view>
			</view>
			<!-- 第二个panel -->
			<view class="panel">
				<!-- 我的订单 -->
				<view class="panel-title">
					我的订单
				</view>
				<view class="panel-body">
					<!-- 待付款 -->
					<view class="panel-item">
						<image src="../../static/image/待付款.png" class="icon" mode=""></image>
						<text>待付款</text>
					</view>
					<!-- 待发货 -->
					<view class="panel-item">
						<image src="../../static/image/待发货.png" class="icon" mode=""></image>
						<text>待发货</text>
					</view>
					<!-- 退款/换货 -->
					<view class="panel-item">
						<image src="../../static/image/退款.png" class="icon" mode=""></image>
						<text>退款/换货</text>
					</view>
					<!-- 全部订单 -->
					<view class="panel-item">
						<image src="../../static/image/全部订单.png" class="icon" mode=""></image>
						<text>全部订单</text>
					</view>

				</view>
			</view>
			<!-- 第三个panel -->
			<view class="panel">
				<view class="panel-list-item">
					<text>收货地址</text>
					<uni-icons type="right" size="20"></uni-icons>

				</view>
				<view class="panel-list-item">
					<text>联系客服</text>
					<uni-icons type="right" size="20"></uni-icons>

				</view>
				<view class="panel-list-item" @click="logout">
					<text>退出登录</text>
					<uni-icons type="right" size="20"></uni-icons>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations

	} from 'vuex'
	export default {
		name: "my-userinfo",
		data() {
			return {

			};
		},
		computed: {
			...mapState('my_user', ['userinfo'])
		},
		methods: {
			...mapMutations('my_user', ['updateToken', 'updateAddress', 'updateUserInfo']),
			async logout() {
				const success = await uni.showModal({
					title: '提示',
					content: '是否确认退出?'
				})
				if (success && success.confirm) {
					this.updateToken('')
					this.updateAddress({})
					this.updateUserInfo({})
				}
			}
		}
	}
</script>

<style lang="scss">
	page,
	.my-userinfo-container {
		height: 100%;
		background-color: #dfdfdff;

		.top-box {
			width: 100%;
			height: 400rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			background-color: #ef5135;

			.avatar {
				width: 90px;
				height: 90px;
				margin-top: 50px;
				border-radius: 50%;
				border: white 2px solid;
				box-shadow: 0 1px 5px black;
			}

			.nickname {
				color: white;
				font-size: 16px;
				margin-top: 10px;
			}
		}


		// 第一个panel的css
		.panel-list {
			position: relative;
			top: -10px;
			padding: 0 10px;
		}

		.panel {
			background-color: white;
			border-radius: 3px;
			margin-bottom: 8px;
		}

		.panel-list-item {
			display: flex;
			justify-content: space-between;
			margin-top: 10px;
			border-bottom: 1px solid #f7f7f7;
			padding: 0 10px;
		}

		.panel-body {
			background-color: white;
			border-radius: 3px;
			margin-bottom: 8px;
			display: flex;
			justify-content: space-around;

			.panel-title {
				line-height: 45px;
				margin-left: 10px;
				font-size: 15px;
				border-bottom: 1px solid #eaeae9;
			}

			.panel-item {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				padding: 10px 0;
				font-size: 13px;

				.icon {
					width: 35px;
					height: 35px;
				}

			}
		}

	}
</style>